package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Appraise;
import com.sk.bilibili.dto.AppraiseInfo;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.AppraiseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 邵康
 * @date 2021/12/03 23:09
 */
@Api(tags = "短评相关")
@CrossOrigin
@RestController
@RequestMapping("/appraise")
public class AppraiseController {

    @Autowired
    private AppraiseService appraiseService;

    @ApiOperation("添加短评，番剧id,分数，内容  必须")
    @PostMapping("/add")
    public R<Void> add(@RequestBody Appraise appraise) {
        return appraiseService.add(appraise);
    }

    @ApiOperation("根据Id删除")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return appraiseService.delete(id);
    }

    @ApiOperation("根据Id更新内容  只能更新分数 与内容")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Appraise appraise) {
        return appraiseService.update(appraise);
    }

    @ApiOperation("获取除了用户评论的分页评论信息")
    @PostMapping("/page")
    public R<IPage<Appraise>> page(@RequestBody AppraiseInfo appraiseInfo) {
        return appraiseService.page(appraiseInfo);
    }

    @ApiOperation("获取当前用户的评论 可能为null")
    @GetMapping("/getAppraise")
    public R<Appraise> getAppraise(Integer themId){
        return appraiseService.getAppraise(themId);
    }

}
